
package no.ne.lexer;

import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;
import static no.ne.psi.CucumberTokenTypes.*;

%%

%class _CucumberLexer
%implements FlexLexer
%unicode
%public

%function advance
%type IElementType

/***** Custom user code *****/
%{
    StringBuffer string = new StringBuffer();
%}
/***** Macros - Regular expressions *****/
LineTerminator=\r|\n|\r\n
InputCharacter=[^\r\n]
WhiteSpace={LineTerminator}|[ \t\f]
WhiteLine=({LineTerminator}[ \t\f]*{LineTerminator})

LineComment=([ \t\f]*"#"{InputCharacter}*)
Tag=([\t\f]*"@"{Char}*)
Digit=[0-9]

Char=[A-Za-z0-9!@#$%<>_/?&\^\+\*\-=\.\?\;\|]
CharLiteral=#\\(newline|space|tab|return|\"|{Char})

Symbol={Char}*

EscapeSequence=\\[^\r\n]
StringLiteral=\"([^\\\"]|{EscapeSequence})*(\"|\\)?
%%
{Tag} { return TAG; }
{LineTerminator} { return EOL; }
{WhiteSpace} { return WHITESPACE; }
{CharLiteral} { return CHAR_LITERAL; }
{LineComment} { return LINE_COMMENT; }
{StringLiteral} { return STRING_LITERAL; }
{Digit} { return DIGIT; }


[Ff][Ee][Aa][Tt][Uu][Rr][Ee] { return FEATURE; }
[Ii][Nn] { return IN; }
[Oo][Rr][Dd][Ee][Rr] { return ORDER; }
[Aa][Ss] { return AS; }
[Aa][Nn] { return AN; }
[Ii] { return I; }
[Ww][Aa][Nn][Tt] { return WANT; }
[Ss][Cc][Ee][Nn][Aa][Rr][Ii][Oo] { return SCENARIO; }
[Gg][Ii][Vv][Ee][Nn] { return GIVEN; }
[Ww][Hh][Ee][Nn] { return WHEN; }
[Tt][Hh][Ee][Nn] { return THEN; }
[Aa][Nn][Dd] { return AND; }

":" { return COMPOSER; }

{Symbol} { return SYMBOL; }

. { return BAD_CHARACTER; }